/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package mascotrin;
import java.sql.*;
import javax.swing.JOptionPane;
/**
 *
 * @author SQL
 */
public class CambiosSQL {
    
    public CambiosSQL(String SQL)
     {
         // Creo el Strin de su Url
//        String connectionUrl= "jdbc:sqlserver://MEZA\\SQLEXPRESS:1433;integratedSecurity=true"+
//			"databaseName=Mascotrin;integratedSecurity=true;";
      	String connectionUrl = "jdbc:sqlserver://localhost:1433;" +
			"databaseName=Mascotrin;integratedSecurity=true;";
//192.168.0.100
		// Declarar  los objectos JDBC.
		Connection con = null;
		Statement stmt = null;
		ResultSet rs = null;
                try {
                
        		// Establish the connection.
                    Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");
                     con = DriverManager.getConnection(connectionUrl);
                        //Inserta Datos a la Tabla de Clientes
                     stmt=con.createStatement();
                   stmt.execute(SQL);
                   System.out.println("Creacion de base de Datos exitosa");
                     }
                  // Handle any errors that may have occurred.
		catch (Exception e) {
                  e.printStackTrace();
                  JOptionPane.showMessageDialog(null,e.getMessage(),"ERROR",JOptionPane.ERROR_MESSAGE);
		}

		finally {
			if (rs != null) try { rs.close(); } catch(Exception e) {}
	    		if (stmt != null) try { stmt.close(); } catch(Exception e) {}
	    		if (con != null) try { con.close(); } catch(Exception e) {}
		}
        
    }

}
